﻿namespace PropertyExpression.ControllableQuery.Test
{
    public class Decimal<TPrecision, TScale>
        where TPrecision : IPrecision
        where TScale : IScale
    {
        private readonly decimal value;

        public Decimal(decimal value)
        {
            this.value = value;
        }

        public decimal Value
        {
            get { return value; }
        }

        public static implicit operator decimal(Decimal<TPrecision, TScale> @decimal)
        {
            return @decimal.Value;
        }

        public override string ToString()
        {
            return Value.ToString();
        }

        private static readonly byte precision = typeof(TPrecision).GetPrecision();
        public static byte Precision
        {
            get { return precision; }
        }

        private static readonly byte scale = typeof(TScale).GetScale();
        public static byte Scale
        {
            get { return scale; }
        }
    }

    public interface IPrecision { }

    public interface IScale { }

    public class P18 : IPrecision { }

    public class S7 : IScale { }
}